package com.example.njupt.sqllite.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.njupt.sqllite.entity.PersonEntity;

/**
 * Author:      mwang
 * Create Date: Created in 2021/5/24 16:52
 * Update Date:
 * Modified By:
 * Description:
 */
@Dao
public interface PersonDao {
    String tableName = "person_table";
    int limit = 10;

    @Insert
    void insert(PersonEntity personEntity);

    @Delete
    void delete(PersonEntity personEntity);

    @Update
    void update(PersonEntity personEntity);

    @Query("SELECT * FROM " + tableName + " WHERE personName = :personName LIMIT 1")
    PersonEntity getPersonEntityLimit(String personName);

    @Query("SELECT * FROM " + tableName + " WHERE personName = :personName")
    PersonEntity getPersonEntity(String personName);

    @Query("DELETE FROM " + tableName + " WHERE personName = :personName")
    void deleteById(String personName);
}
